package com.da.javatest.leetCode;

import java.util.HashSet;
import java.util.Set;

/**
 * @author chenlida
 * @date 2018/12/11 11:01
 * @description
 */
public class Code929 {
    public static void main(String[] args) {
        String[] emails = {"test.email+alex@leetcode.com", "test.e.mail+bob.cathy@leetcode.com",
            "testemail+david@lee.tcode.com"};
        new Code929().numUniqueEmails(emails);
    }

    public int numUniqueEmails(String[] emails) {
        Set<String> emailSet = new HashSet<>();
        for (String email : emails) {
            String[] s1 = email.split("@");
            if (s1.length != 2) {
                continue;
            }
            String[] s2 = s1[0].split("\\+");
            String s = s2[0].replace(".", "");
            emailSet.add(s + "@" + s1[1]);
        }
        return emailSet.size();
    }
}
